#include "StdAfx.h"
#include "GameToolApp.h"
#include "MainFrame.h"
#include "TranslationHelper.h"
#include "GameToolMeditator.h"
#include "ViewPanel3D.h"

#include <GameLib/GameManager.h>
#include <GameLib/EngineFacade.h>
#include <GameLib/CAMERA_STYLE.h>
#include <GameLib/ParticleObject.h>
#include <DebugUtils/DebugUtils.h>

#include <boost/timer.hpp>

IMPLEMENT_APP(GameToolApp);

bool GameToolApp::OnInit()
{
	//_crtBreakAlloc = 80643;
	mEditingParticle = 0;
	m_pTranslationHelper = new TranslationHelper(*this);
	mGameToolMeditator.reset(new GameToolMeditator(this));
	if (!m_pTranslationHelper->GetLocale())
		SelectLanguage();
	wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED);
	bool success = InitializeGameManager();
	if (!success)
	{
		Exit();
	}

	RecreateGUI();

	

	success = LinkViewPanelToGameEngine(RENDER_WINDOW_MAIN);

	// Create a default scene and a default camera.
	// Entering ToolSceneState
	SetupDefaultScene();	

	// After creating first render window(at this time d3d device is created) load coordinate needle
	mGameToolMeditator->CreateCoordinateNeedle();

	mMainFrame->RefreshParticleSystemTree();
	mMainFrame->RefreshMeshTree();

	if (!success)
	{
		Exit();
	}

	return true;
}

int GameToolApp::OnExit()
{
	//UnlinkViewPanelFromGameEngine(RENDER_WINDOW_MAIN);
	FinalizeGameManager();
	wxDELETE(m_pTranslationHelper);
	return 0;
}

bool GameToolApp::InitializeGameManager()
{
#ifdef _DEBUG
    std::string strResourcesCfg = "resources_d.cfg";
    std::string strPluginsCfg = "plugins_d.cfg";
#else
    std::string strResourcesCfg = "resources.cfg";
    std::string strPluginsCfg = "plugins.cfg";
#endif
	bool success = EngineFacade::InitializeOgre(strPluginsCfg.c_str(), strResourcesCfg.c_str());
	if (!success)
	{
		DebugUtils::Warning(DEFAULT_DEBUG_ARG, "Initializing Engine has failed.");
		wxMessageBox(_("Initialzing Engine has failed."));		
		return false;
	}

	success = GameManager::Initialize(strPluginsCfg.c_str(), strResourcesCfg.c_str());
	if (!success)
	{
		DebugUtils::Warning(DEFAULT_DEBUG_ARG, "Initializing GameManager has failed.");
		wxMessageBox(_("Initializing GameManager has failed."));		
		return false;
	}

	return true;
}

void GameToolApp::FinalizeGameManager()
{
	GameManager::Finalize();
	EngineFacade::FinalizeOgre();
}

void GameToolApp::RecreateGUI()
{	
	wxWindow* topwindow = GetTopWindow();
	if(topwindow)
	{
		SetTopWindow(NULL);
		topwindow->Destroy();
	}

	mMainFrame = new MainFrame(_("GameTool"), wxSize(1600, 1000) );
	SetTopWindow(mMainFrame);
	mMainFrame->Show();
}

// Create an Engine Render Window
bool GameToolApp::LinkViewPanelToGameEngine(RENDER_WINDOW_ID renderWindowID)
{
	ViewPanel3D* pViewPanel = mMainFrame->GetViewPanel3D(renderWindowID);
	if (!pViewPanel)
	{
		DebugUtils::Warning(DEFAULT_DEBUG_ARG, "Can't retrieve the ogre view panel with following index.");
		DebugUtils::Warning("	viewPanelIndex = %d", renderWindowID);
		return false;
	}

	int handle = (int)pViewPanel->GetHandle();
	wxSize size = pViewPanel->GetSize();
	wxString windowName = pViewPanel->GetRenderWindowName();
	bool success = EngineFacade::CreateRenderWindow(handle, size.x, size.y, windowName.mb_str());
	if (!success)
	{
		DebugUtils::Warning(DEFAULT_DEBUG_ARG, "Create an engine render window has failed.");
		wxMessageBox(_("Create an engine render window has failed."));		
		return false;
	}

	return true;
}

void GameToolApp::UnlinkViewPanelFromGameEngine(RENDER_WINDOW_ID renderWindowID)
{
	wxWindow* pViewPanel = mMainFrame->GetViewPanel3D(renderWindowID);
	if (!pViewPanel)
	{
		DebugUtils::Warning(DEFAULT_DEBUG_ARG, "Can't retrieve the ogre view panel with following index.");
		DebugUtils::Warning("	viewPanelIndex = %d", renderWindowID);
		return;
	}

	int handle = (int)pViewPanel->GetHandle();
	wxString windowName = wxString::Format(_T("RenderWindow%d"), handle);
	EngineFacade::DestroyRenderWindow(windowName.mb_str());
}

bool GameToolApp::SelectLanguage()
{
	wxArrayString names;
	wxArrayLong identifiers;
	m_pTranslationHelper->GetInstalledLanguages(names, identifiers);
	if (m_pTranslationHelper->AskUserForLanguage(names, identifiers))
	{
		m_pTranslationHelper->Save();
		RecreateGUI();
		return true;
	}
	return false;
}

void GameToolApp::OnFrame()
{
	static boost::timer timer;
	if ( !mMainFrame->IsActive() )
		return;
	float deltaTime = timer.elapsed();
	if (deltaTime>0.5f)
		deltaTime = 0.5f;
	timer.restart();
	
	GameManager::GetSingleton().Render(deltaTime);
	GameManager::GetSingleton().Update(deltaTime);
	
	mMainFrame->CheckFileModification();
}

bool GameToolApp::OnMouse(wxMouseEvent& e)
{
	static wxCoord prevX = e.GetX();
	static wxCoord prevY = e.GetY();
	
	MouseInput input;
	input.curX = e.GetX();
	input.curY = e.GetY();
	input.curZ = e.GetWheelRotation();
	input.leftButtonDown = e.LeftIsDown();
	input.leftButtonUp = e.LeftUp();
	input.middleButtonDown = e.MiddleIsDown();
	input.middleButtonUp = e.MiddleUp();
	input.rightButtonDown = e.RightIsDown();
	input.rightButtonUp = e.RightUp();
	input.prevX = prevX;
	input.prevY = prevY;
	input.positionChanged = 
		(input.curX != prevX || input.curY != prevY);
	
	bool furtherProcess = GameManager::GetSingleton().MouseChanged(input);

	prevX = e.GetX();
	prevY = e.GetY();

	return furtherProcess;
}

bool GameToolApp::OnKeyDown(wxKeyEvent& e)
{
	KeyboardInput input;
	input.keyCode = e.GetKeyCode();
	input.alt = e.AltDown();
	input.shift = e.ShiftDown();
	input.ctrl = e.ControlDown();
	bool furtherProcess = GameManager::GetSingleton().KeyPressed(input);

	return furtherProcess;
}

bool GameToolApp::OnKeyUp(wxKeyEvent& e)
{
	KeyboardInput input;
	input.keyCode = e.GetKeyCode();
	input.alt = e.AltDown();
	input.shift = e.ShiftDown();
	input.ctrl = e.ControlDown();
	bool furtherProcess = GameManager::GetSingleton().KeyReleased(input);
	return furtherProcess;
}

bool GameToolApp::OnChar(wxKeyEvent& e)
{
	KeyboardInput input;
	input.unicode = e.GetUnicodeKey();
	bool furtherProcess = GameManager::GetSingleton().KeyChar(input);
	return furtherProcess;
}

void GameToolApp::OnMove(wxMoveEvent& e)
{
	wxRect r = mMainFrame->GetViewPanel3D(RENDER_WINDOW_MAIN)->GetScreenRect();
	mGameToolMeditator->SetViewportRegion(r.x, r.y, r.width, r.height);
}

void GameToolApp::OnSize(const wxString& renderWindowName, wxSize size, wxRect rect)
{
	EngineFacade::Resize(renderWindowName.mb_str(), size.x, size.y);
	mGameToolMeditator->SetViewportRegion(rect.x, rect.y, rect.width, rect.height);
}

void GameToolApp::SetFocusToMainViewPanel()
{
	ViewPanel3D* pViewPanel = mMainFrame->GetViewPanel3D(RENDER_WINDOW_MAIN);
	if (!pViewPanel)
	{
		DebugUtils::Warning(DEFAULT_DEBUG_ARG, "Can't retrieve the ogre view panel with following index.");
		DebugUtils::Warning("	viewPanelIndex = %d", RENDER_WINDOW_MAIN);
		return;
	}
	pViewPanel->SetFocus();
}

void GameToolApp::UpdateParticleSystemTemplate(const wxString& strScript)
{
	ResourceUpdateResult ur = EngineFacade::UpdateParticleSystemTemplate(strScript.mb_str());
	unsigned size = ur.errors.size();
	for (unsigned i=0; i<size; i++)
	{
		Message(wxString::FromAscii(ur.errors[i].c_str()));
	}
	SCENE_TYPE sceneType = GameManager::GetSingleton().GetCurrentSceneType();
	if (mEditingParticle)
		mGameToolMeditator->RemoveParticleSystem(sceneType, mEditingParticle);

	if (!ur.updatedResourceNames.empty())
	{
		float height = mGameToolMeditator->GetTerrainHeight(0, 0);
		mEditingParticle = dynamic_cast<ParticleObject*>
			(mGameToolMeditator->AddParticleSystems(sceneType, 0.f, height + 1.8f, 0.f, 
			ur.updatedResourceNames) );
		if (mEditingParticle)
		{
			Message(_("Particles applied to the view."));
		}
		else
		{
			Message(_("No particle object is renewed or created."));
		}
	}
	
}

void GameToolApp::UpdateMaterial(const wxString& strScript)
{
	ResourceUpdateResult ur = EngineFacade::UpdateMaterial(strScript.mb_str());
	unsigned size = ur.errors.size();
	for (unsigned i=0; i<size; i++)
	{
		Message(wxString::FromAscii(ur.errors[i].c_str()));
	}
	
	if (mEditingParticle)
	{
		bool success = mEditingParticle->ReloadParticleSystem();
		if (success)
		{
			mMainFrame->Message(_("Material applied to the view."));
		}
		else
		{
			DebugUtils::Warning(DEFAULT_DEBUG_ARG, "ReloadParticleSystem failed.");
		}
	}
}

bool GameToolApp::CreateTerrain(float worldSize, int terrainSize, const char* filename)
{
	bool success = mGameToolMeditator->CreateTerrain(worldSize, terrainSize, filename);
	if (success)
	{
		mMainFrame->UpdateTerrainVisibilityMenu();
	}
	else
	{
		Message(_("Failed to create a terrain."));
	}

	return success;
}

bool GameToolApp::SaveTerrain(const char* filename)
{
	bool success = mGameToolMeditator->SaveTerrain(filename);
	if (success)
	{
		Message(_("Terrain saved."));
	}
	else
	{
		Message(_("Failed to save terrain."));
	}
	return success;
}

bool GameToolApp::LoadTerrain(const char* filename)
{
	bool success = mGameToolMeditator->LoadTerrain(filename);
	if (success)
	{
		Message(_("Terrain loaded."));
	}
	else
	{
		Message(_("Failed to load terrain."));
	}
	return success;
}

bool GameToolApp::IsTerrainModified() const
{
	return mGameToolMeditator->IsTerrainModified();
}

void GameToolApp::SetCameraStyle(unsigned cameraNumber)
{
	mGameToolMeditator->SetCameraStyle((CAMERA_STYLE) cameraNumber);
}

bool GameToolApp::IsTerrainShown() const
{
	return mGameToolMeditator->IsTerrainShown();
}

void GameToolApp::ShowTerrain(bool show/* = true*/)
{
	mGameToolMeditator->ShowTerrain(show);
}

void GameToolApp::SetTerrainEditMode(TERRAIN_EDIT_MODE editMode, unsigned blendMapIndex /*=1*/) 
{
	mGameToolMeditator->SetTerrainEditMode(editMode, blendMapIndex);
}

// brushName: in BrushStrings.h
void GameToolApp::SetTerrainHeightBrush(const char* brushName) 
{
	mGameToolMeditator->SetTerrainHeightBrush(brushName);
}

void GameToolApp::SetTerrainBrushSize(float size)
{
	mGameToolMeditator->SetTerrainBrushSize(size);
}

void GameToolApp::SetTerrainBrushWeight(float weight)
{
	mGameToolMeditator->SetTerrainBrushWeight(weight);
}

void GameToolApp::SetTerrainBrushConstantHeight(float size)
{
	mGameToolMeditator->SetTerrainBrushConstantHeight(size);
}

bool GameToolApp::GetTerrainLayerInfo(TerrainLayerInfo& info)
{
	return mGameToolMeditator->GetTerrainLayerInfo(info);
}

bool GameToolApp::SetDiffuseSpecularMap(unsigned index, const char* textureName)
{
	return mGameToolMeditator->SetDiffuseSpecularMap(index, textureName);
}

bool GameToolApp::SetNormalHeightMap(unsigned index, const char* textureName)
{
	return mGameToolMeditator->SetNormalHeightMap(index, textureName);
}

bool GameToolApp::SetLayerWorldSize(unsigned index, float worldSize)
{
	return mGameToolMeditator->SetLayerWorldSize(index, worldSize);
}

unsigned GameToolApp::AddTerrainLayer()
{
	unsigned count = mGameToolMeditator->AddTerrainLayer();
	return count;
}

bool GameToolApp::RemoveTerrainLayer(unsigned index)
{
	bool success = mGameToolMeditator->RemoveTerrainLayer(index);
	if (!success)
	{
		Message(_("Failed to delete a terrain layer. No terrain exists."));
	}
	return success;
}

bool GameToolApp::UseTerrainNormalHeightMap(bool use)
{
	return mGameToolMeditator->UseTerrainNormalHeightMap(use);
}

int GameToolApp::GetCurrentLocale()
{
	return m_pTranslationHelper->GetLocale()->GetLanguage();
}

void GameToolApp::ShowBoundingBox(bool show)
{
	mGameToolMeditator->ShowBoundingBox(show);
}

bool GameToolApp::IsSceneModified() const
{
	return mGameToolMeditator->IsSceneModified();
}

void GameToolApp::ClearScene()
{
	mGameToolMeditator->ClearScene();
}

void GameToolApp::SaveScene(const char* filepath)
{
	mGameToolMeditator->SaveScene(filepath);
	Message(_T("Scene saved."));
}

bool GameToolApp::LoadScene(const char* filepath)
{
	return mGameToolMeditator->LoadScene(filepath);
}

void GameToolApp::EnablePhysicsDebug(bool enable)
{
	GameManager::GetSingleton().EnablePhysicsDebugRender(enable);
}


void GameToolApp::SetAnimationInfo(const AnimationInformation& info)
{
	mMainFrame->SetAnimationInfo(info);
}

void GameToolApp::OnPositionChanged(float x, float y, float z)
{
	mMainFrame->SetTransformPosition(x, y, z);
}

void GameToolApp::OnScaleChanged(float x, float y, float z)
{
	mMainFrame->SetTransformScale(x, y, z);
}

void GameToolApp::UpdateSpotInfoTool(const SpotInfo& spotinfo)
{
	mMainFrame->UpdateSpotInfoTool(spotinfo);
}

void GameToolApp::UpdateSpotPathTool(const SpotPath& spotPath)
{
	mMainFrame->UpdateSpotPathTool(spotPath);
}

void GameToolApp::UpdateTroopList()
{
	mMainFrame->UpdateTroopList();
}

void GameToolApp::MsgFromGame(const char* msg)
{
	Message(wxString(msg, gCSConv));
}

void GameToolApp::UpdateEntityType(const char* entityType)
{
	mMainFrame->UpdateEntityType(entityType);
}

void GameToolApp::OnRotationChanged(float x, float y, float z) //Euler xyz
{
	mMainFrame->SetTransformRotation(x, y, z);
}

void GameToolApp::OnEditPosition(float x, float y, float z)
{
	mGameToolMeditator->OnEditTranslation(x, y, z);
}

void GameToolApp::OnEditRotation(float x, float y, float z)
{
	mGameToolMeditator->OnEditRotation(x, y, z);
}

void GameToolApp::OnEditScale(float x, float y, float z)
{
	mGameToolMeditator->OnEditScale(x, y, z);
}

void GameToolApp::OnCameraStyleSwitching()
{
	if (mMainFrame->IsEditingWorldMap())
	{
		return;
	}
	CAMERA_STYLE cs = mGameToolMeditator->GetCameraStyle();
	static CAMERA_STYLE loop[4] = {CS_TRACKBALL, CS_FLYING, CS_WALKING, CS_GAME};
	int curIdx = 0;
	for (int i=0; i<4; i++)
	{
		if (loop[i]==cs)
		{
			curIdx = i;
			break;
		}
	}
	int nextIdx = curIdx + 1;
	if (nextIdx > 3)
		nextIdx = 0;
	CAMERA_STYLE nextType = loop[nextIdx];
	
	mGameToolMeditator->SetCameraStyle(nextType);
	mMainFrame->CheckCameraMenuItem(nextType);
}

void GameToolApp::Message(const wxString& msg)
{
	mMainFrame->Message(msg);
}

void GameToolApp::RefocusCamera()
{
	mGameToolMeditator->RefocusCamera();
}

void GameToolApp::RemoveParticleSystem(const char* nodeName)
{
	SCENE_TYPE type = GameManager::GetSingleton().GetCurrentSceneType();
	mGameToolMeditator->RemoveParticleSystem(type, nodeName);
}

// Create a ToolScene and a ParticleEditorScene
void GameToolApp::SetupDefaultScene()
{
	ViewPanel3D* pViewPanel = mMainFrame->GetViewPanel3D(RENDER_WINDOW_MAIN);
	assert(pViewPanel);
	std::string renderWindowName = pViewPanel->GetRenderWindowName().mb_str();
	GameManager& gm = GameManager::GetSingleton();
	// GameLib using 'DefaultScene' as the default name of the scene. defined in ToolScene.h
	bool success = gm.CreateToolScene(OST_GENERIC, SCENE_NAME_MAIN, renderWindowName.c_str(), mGameToolMeditator.get());
	PushToolSceneState();

	success = gm.CreateParticleEditorScene(SCENE_NAME_PARTICLE_EDITOR_SCENE, renderWindowName.c_str(), mGameToolMeditator.get());
	
	//! Update Viewport region
	OnMove(wxMoveEvent());
}

bool GameToolApp::CreateWorldMapScene(const WorldMapCreationDesc& desc)
{
	ViewPanel3D* pViewPanel = mMainFrame->GetViewPanel3D(RENDER_WINDOW_MAIN);
	assert(pViewPanel);
	std::string renderWindowName = pViewPanel->GetRenderWindowName().mb_str();
	GameManager& gm = GameManager::GetSingleton();
	bool success = gm.CreateWorldMapScene(desc, SCENE_NAME_WORLD_MAP_SCENE, renderWindowName.c_str(), mGameToolMeditator.get());
	PushWorldMapSceneState();
	
	//! Update Viewport region
	OnMove(wxMoveEvent());
	return success;	
}

bool GameToolApp::CreateEmptyWorldMapScene()
{
	ViewPanel3D* pViewPanel = mMainFrame->GetViewPanel3D(RENDER_WINDOW_MAIN);
	assert(pViewPanel);
	std::string renderWindowName = pViewPanel->GetRenderWindowName().mb_str();
	GameManager& gm = GameManager::GetSingleton();
	bool success = gm.CreateWorldMapScene(WorldMapCreationDesc(), SCENE_NAME_WORLD_MAP_SCENE, renderWindowName.c_str(), mGameToolMeditator.get());
	PushWorldMapSceneState();
	
	//! Update Viewport region
	OnMove(wxMoveEvent());
	return success;
}

void GameToolApp::SaveWorldMapScene(const char* filepath)
{
	mGameToolMeditator->SaveWorldMapScene(filepath);
	Message(_("World map saved."));
}

void GameToolApp::LoadWorldMapScene(const char* filename)
{
	bool result = mGameToolMeditator->LoadWorldMapScene(filename);
	if (!result) {
		Message(_("Loading world map failed!"));
	} else {
		Message(_("Worldmap loaded."));
	}
}

bool GameToolApp::IsWorldMapModifiedSinceLastSave()
{
	return mGameToolMeditator->IsWorldMapModifiedSinceLastSave();
}

void GameToolApp::SetEditingTroopID(unsigned id)
{
	mGameToolMeditator->SetEditingTroopID(id);
}

bool GameToolApp::CreateParticleEditorScene()
{
	ViewPanel3D* pViewPanel = mMainFrame->GetViewPanel3D(RENDER_WINDOW_MAIN);
	assert(pViewPanel);
	std::string renderWindowName = pViewPanel->GetRenderWindowName().mb_str();
	GameManager& gm = GameManager::GetSingleton();
	bool success = gm.CreateParticleEditorScene(SCENE_NAME_PARTICLE_EDITOR_SCENE, renderWindowName.c_str(), mGameToolMeditator.get());

	OnMove(wxMoveEvent());
	return success;
}

void GameToolApp::AddParticleSystems(wxCoord x, wxCoord y, std::vector<std::string>& templateNames)
{
	SCENE_TYPE type = GameManager::GetSingleton().GetCurrentSceneType();
	mGameToolMeditator->AddParticleSystems(type, x, y, templateNames);
}

void GameToolApp::AddRigidMesh(wxCoord x, wxCoord y, const wxString& resourceName)
{
	mGameToolMeditator->AddRigidMesh(x, y, resourceName.mb_str());
}

void GameToolApp::frameRenderingQueued(float deltaTime)
{
	
}

void GameToolApp::OnEnteringToolScene(const char* path)
{
	mMainFrame->OnEnteringToolScene(path);
}

void GameToolApp::PopSceneState()
{
	if (GameManager::IsInitialized())
	{
		GameManager::GetSingleton().PopGameState();
	}
}

//void GameToolApp::PopWorldMapSceneState()
//{
//	if (GameManager::IsInitialized())
//	{
//		GameManager::GetSingleton().PopGameState(DEFAULT_WORLD_MAP_SCENE_NAME);
//	}
//}

void GameToolApp::PushWorldMapSceneState()
{
	if (GameManager::IsInitialized())
	{
		GameManager::GetSingleton().PushGameState(SCENE_NAME_WORLD_MAP_SCENE);
	}
}

void GameToolApp::PushToolSceneState()
{
	if (GameManager::IsInitialized())
	{
		GameManager::GetSingleton().PushGameState(SCENE_NAME_MAIN);
	}
}

void GameToolApp::PushDotEditorSceneState()
{
	if (GameManager::IsInitialized())
	{
		GameManager::GetSingleton().PushGameState(SCENE_NAME_DOT_EDITOR_SCENE);
	}
}

void GameToolApp::PushParticleEditorSceneState()
{
	if (GameManager::IsInitialized())
	{
		GameManager::GetSingleton().PushGameState(SCENE_NAME_PARTICLE_EDITOR_SCENE);
	}
}

void GameToolApp::SetWorldMapEditMode(WORLDMAP_EDIT_MODE mode)
{
	mGameToolMeditator->SetWorldMapEditMode(mode);
}

void GameToolApp::SetWorldMapAddingSpotType(SPOT_TYPE type)
{
	mGameToolMeditator->SetWorldMapAddingSpotType(type);
}

const char* GameToolApp::GetWorldmapSpotName(unsigned id) const
{
	return mGameToolMeditator->GetWorldmapSpotName(id);
}

void GameToolApp::SetWorldMapSpotName(const char* name)
{
	mGameToolMeditator->SetWorldMapSpotName(name);
}

void GameToolApp::SetWorldMapSpotType(SPOT_TYPE type)
{
	mGameToolMeditator->SetWorldMapSpotType(type);
}

void GameToolApp::PlayAnimation(const char* name)
{
	mGameToolMeditator->PlayAnimation(name);
}

void GameToolApp::StopAnimation()
{
	mGameToolMeditator->StopAnimation();
}

void GameToolApp::SetGameEntityType(const char* entityTypeName)
{
	mGameToolMeditator->SetGameEntityType(entityTypeName);
}

void GameToolApp::StartRagdoll()
{
	mGameToolMeditator->StartRagdoll();
}

void GameToolApp::EnableTransformer(bool enable)
{
	mGameToolMeditator->EnableTransformer(enable);
}

bool GameToolApp::NeedToSaveDotObject() const
{
	return mGameToolMeditator->NeedToSaveDotObject();
}
void GameToolApp::SetupNewDotCharacter(unsigned countX, unsigned countY, unsigned  countZ,
		float size,
		int originX, int originY, int originZ)
{
	mGameToolMeditator->SetupNewDotCharacter(countX, countY, countZ, size,
		originX, originY, originZ);
}

void GameToolApp::SetupNewDotProp(unsigned countX, unsigned countY, unsigned  countZ,
		float size,
		int originX, int originY, int originZ)
{
	mGameToolMeditator->SetupNewDotProp(countX, countY, countZ, size, 
		originX, originY, originZ);
}

void GameToolApp::SetDotCount(unsigned x, unsigned y, unsigned z)
{
	mGameToolMeditator->SetDotCount(x, y, z);
}

void GameToolApp::SetDotSize(float size)
{
	mGameToolMeditator->SetDotSize(size);
}

void GameToolApp::SetDotOrigin(int originX, int originY, int originZ)
{
	mGameToolMeditator->SetDotOrigin(originX, originY, originZ);
}

void GameToolApp::SaveDotObject(const char* filepath)
{
	mGameToolMeditator->SaveDotObject(filepath);
}

void GameToolApp::SetMainFrameTitle(const wxString& strTitle)
{
	mMainFrame->SetTitle(strTitle);
}